package com.smarthealthring.mm.presenter;

import android.util.Log;

import com.smarthealthring.mm.api.ApiRequest;
import com.smarthealthring.mm.base.BasePresenter;
import com.smarthealthring.mm.contract.StepDetailContract;
import com.smarthealthring.mm.utils.ErrorHanding;
import com.smarthealthring.mm.utils.ToastUtil;

import java.util.Map;

/**
 * Created by bilibili on 2018/5/26.
 */

public class StepDetailPresenter extends BasePresenter<StepDetailContract.View> implements StepDetailContract.Presenter {

    @Override
    public void stepDetail(Map<String, String> params) {
        addSubscribe(ApiRequest.stepDetail(params)
                .subscribe(response -> {
                    Log.e("stepDetail===","success");
                    mView.getStepDetailSuccess(response);
                }, throwable -> {
                    mView.getStepDetailFail();
                    Log.e("stepDetail===",throwable.toString());
                    ToastUtil.shortShow(ErrorHanding.handleError(throwable));
                }));
    }
}
